def counting_sort(A, B, k):
    C = [0]*(k+1)
    for j in range(len(A)):
        C[A[j]] = C[A[j]]+1
    for i in range(1,k+1):
        C[i] = C[i]+C[i-1]
    for j in range(len(A)-1, -1, -1):
        B[C[A[j]]-1] = A[j]
        C[A[j]] = C[A[j]]-1


A = [2, 5, 3, 0, 2, 3, 0, 3]
B = [0]*len(A)
k = max(A)
counting_sort(A, B, k)
print(B)

